﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace calculation.Models
{
    public class DataManager
    {


        private UchetDataContext _datacontext;

        public DataManager(string connectionString)
        {
            _datacontext = new UchetDataContext(connectionString);
        }
        private MembershipRepository _membershipRepository;
        public MembershipRepository Membership
        {
            get
            {
                if (_membershipRepository == null)
                    _membershipRepository = new MembershipRepository();

                return _membershipRepository;
            }
        }

        private OrderRepository _orderRepository;
        public OrderRepository Orders
        {
            get
            {
                if (_orderRepository == null)
                    _orderRepository = new OrderRepository(_datacontext);

                return _orderRepository;
            }

        }

        private StateRepository _stateRepository;
        public StateRepository States
        {
            get
            {
                if (_stateRepository == null)
                    _stateRepository = new StateRepository(_datacontext);

                return _stateRepository;
            }

        }

        private ProducerRepository _producerRepository;
        public ProducerRepository Producers
        {
            get
            {
                if (_producerRepository == null)
                    _producerRepository = new ProducerRepository(_datacontext);

                return _producerRepository;
            }

        }
        private MaterialRepository _materialRepository;
        public MaterialRepository Materials
        {
            get
            {
                if (_materialRepository == null)
                    _materialRepository = new MaterialRepository(_datacontext);

                return _materialRepository;
            }

        }

        private DetalRepository _detalRepository;
        public DetalRepository Detals
        {
            get
            {
                if (_detalRepository == null)
                    _detalRepository = new DetalRepository(_datacontext);

                return _detalRepository;
            }

        }
    }
}